package com.skyeye;

import com.skyeye.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import static org.junit.Assert.*;

/**
 * MyBatis配置测试类
 * 用于验证MyBatis配置是否正确
 */
public class MyBatisConfigTest {
    
    /**
     * 测试MyBatis配置加载
     */
    @Test
    public void testMyBatisConfig() {
        try {
            // 尝试获取SqlSessionFactory
            assertNotNull("SqlSessionFactory不应该为null", MyBatisUtil.getSqlSessionFactory());
            
            // 尝试获取SqlSession
            SqlSession sqlSession = MyBatisUtil.getSqlSession();
            assertNotNull("SqlSession不应该为null", sqlSession);
            
            // 关闭SqlSession
            MyBatisUtil.closeSqlSession(sqlSession);
            
            System.out.println("✅ MyBatis配置加载成功！");
            
        } catch (Exception e) {
            fail("MyBatis配置加载失败: " + e.getMessage());
        }
    }
}
